const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
  transpileDependencies: true,

  devServer: {
    port: 3000, // 监听端口
    proxy: {
      '/api': {
        target: 'http://localhost:8080', // 后端端口
        changeOrigin: true,
        pathRewrite: {
          '^/api': ''
        },
        logLevel: 'debug', // 添加调试日志
        onProxyReq(proxyReq, req, res) {
          console.log('代理请求:', req.method, req.url)
        },
        onProxyRes(proxyRes, req, res) {
          console.log('代理响应:', proxyRes.statusCode, req.url)
        },
        onError(err, req, res) {
          console.error('代理错误:', err)
        }
      }
    }
  }
})
